const 
	express = require('express'),
	hbs = require('hbs'),
	path = require('path'),
	utils = require('../utils/utils'),
	routes = require('./routes'),
	staticPath = path.resolve(__dirname, '../public'),
	app = express()
;

app.set('port', process.env.PORT || 3000);
app.set('views', path.resolve(__dirname, '../public/views'));
app.set('view engine', 'html');
app.engine('html', hbs.__express);

app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
// 下面两行的顺序很重要
app.use(express.static(staticPath));
app.use(app.router);

app.listen(app.get('port'));
routes(app);